var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function o() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((o.prototype = i.prototype), new o()));
      };
    })(),
  forcejewel = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        t.btn_force_back.on(Laya.Event.CLICK, t, t.onForceJewelBackFn),
        t.btn_jewel_kaishiqiangbao.on(
          Laya.Event.CLICK,
          t,
          t.onDidClickStartAction
        ),
        t.btn_force_GZSM.on(Laya.Event.CLICK, t, t.onDidForceAction),
        t.btn_force_JLSM.on(Laya.Event.CLICK, t, t.onDidForceAction),
        t.btn_jewel_item1.on(Laya.Event.CLICK, t, t.onForceJewelActionFn),
        t.btn_jewel_item2.on(Laya.Event.CLICK, t, t.onForceJewelActionFn),
        t.btn_jewel_item3.on(Laya.Event.CLICK, t, t.onForceJewelActionFn),
        (t.list_forcejewel.selectEnable = !0),
        (t.list_forcejewel.vScrollBarSkin = ""),
        WebSocketService.addListener({
          caller: t,
          code: 22,
          method: t.onLoadForceJewelData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 2056,
          method: t.onLoadStartQiangBaoData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 2057,
          method: t.onLoadCurrentPersonListData,
        }),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showForceJewelView = function () {
        null == this.forceV && (this.forceV = new t()),
          this.forceV.initJewelView();
        var e = Math.floor(Global.roleLvl / 10),
          i = 0;
        return (
          (i = Global.roleLvl > 110 ? 10 : e),
          WebSocketService.send({ c: 22, d: { lvl: i } }),
          WebSocketService.send({ c: 2057, d: { lvl: i } }),
          this.forceV
        );
      }),
      (t.prototype.initJewelView = function () {
        this.second = 60;
        var e = Global.roleLvl,
          t = Math.floor(e / 10);
        this.currentModel = Math.floor(e / 10) + "";
        var i = "您当前" + e + "级，请前往" + this.currentModel + "级宝藏";
        1 == t
          ? ((this.btn_jewel_item1.visible = !1),
            (this.btn_jewel_item2.visible = !0),
            (this.btn_jewel_item3.visible = !0),
            (this.btn_jewel_item2.label = "1级"),
            (this.btn_jewel_item3.label = "2级"))
          : 10 == t
          ? ((this.btn_jewel_item1.visible = !0),
            (this.btn_jewel_item2.visible = !0),
            (this.btn_jewel_item3.visible = !1),
            (this.btn_jewel_item1.label = "9级"),
            (this.btn_jewel_item2.label = "10级"))
          : ((this.btn_jewel_item1.visible = !0),
            (this.btn_jewel_item2.visible = !0),
            (this.btn_jewel_item3.visible = !0),
            (this.btn_jewel_item1.label = t - 1 + "级"),
            (this.btn_jewel_item2.label = t + "级"),
            (this.btn_jewel_item3.label = t + 1 + "级")),
          (this.leftLv = t - 1 + "级"),
          (this.middleLv = t + "级"),
          (this.rightLv = t + 1 + "级"),
          (this.label_jewel_level_number.text = i),
          this.allowForceJewel(!0);
      }),
      (t.prototype.onForceJewelActionFn = function (e) {
        var t = Global.roleLvl,
          i = (Math.floor(t / 10), parseInt(this.currentModel));
        if ("item1" == e.target.name)
          9 == --i
            ? (this.btn_jewel_item3.visible = !0)
            : 1 == i && (this.btn_jewel_item1.visible = !1);
        else if ("item2" == e.target.name);
        else if ("item3" == e.target.name) {
          if ((1 == i && (this.btn_jewel_item1.visible = !0), ++i > 10))
            return void i--;
          10 == i && (this.btn_jewel_item3.visible = !1);
        }
        (this.currentModel = i + ""),
          (this.btn_jewel_item1.label = i - 1 + "级"),
          (this.btn_jewel_item2.label = i + "级"),
          (this.btn_jewel_item3.label = i + 1 + "级"),
          this.dealCurrentMatchTitle(this.currentModel),
          this.currentModel == Math.floor(t / 10) + ""
            ? this.allowForceJewel(!0)
            : this.allowForceJewel(!1),
          WebSocketService.send({ c: 2057, d: { lvl: i } });
      }),
      (t.prototype.onLoadForceJewelData = function (e) {
        if (0 != e.code)
          return (
            ToastView.toastView(e.msg),
            (this.label_jewel_time_count.text = "请等待宝藏开启"),
            this.allowForceJewel(!1),
            (this.btn_jewel_kaishiqiangbao.visible = !0),
            (this.btn_jewel_kaishiqiangbao.disabled = !0),
            void (this.label_jewel_level_number.visible = !1)
          );
        (this.label_jewel_time_count.text = "挖宝开启中..."),
          (this.timeDiff = e.data.t),
          0 != this.timeDiff &&
            Laya.timer.loop(1e3, this, this.timerCountDownJewelFn);
      }),
      (t.prototype.onLoadCurrentPersonListData = function (e) {
        for (var t, i = [], o = 0; o < e.data.length; o++) {
          var l = e.data[o],
            n = l.n,
            a = n;
          l.n2 && (a = n + "VS" + l.n2),
            (t = { item_forcejewel: { text: a } }),
            i.push(t);
        }
        this.list_forcejewel.dataSource = i;
      }),
      (t.prototype.timerCountDownJewelFn = function () {
        this.timeDiff--;
        var e = 0,
          t = 0,
          i = 0,
          o = 0;
        (e = Math.floor(this.timeDiff / 86400)),
          (t = Math.floor((this.timeDiff % 86400) / 3600)),
          (i = Math.floor((this.timeDiff % 3600) / 60)),
          (o = Math.floor(this.timeDiff % 60)),
          e <= 0 && t <= 0 && i <= 0 && o <= 1
            ? (Laya.timer.clear(this, this.timerCountDownJewelFn),
              (this.label_jewel_time_count.text = "请稍等挖宝开始..."))
            : o % 20 == 0
            ? (Laya.timer.clear(this, this.timerCountDownJewelFn),
              (this.label_jewel_time_count.text = this.dealTimeDataWithParams(
                e,
                t,
                i,
                o
              )))
            : (this.label_jewel_time_count.text = this.dealTimeDataWithParams(
                e,
                t,
                i,
                o
              ));
      }),
      (t.prototype.dealTimeDataWithParams = function (e, t, i, o) {
        var l = "0秒";
        e > 0
          ? (l = e + "天" + t + "小时" + i + "分" + o + "秒")
          : t > 0
          ? (l = t + "小时" + i + "分" + o + "秒")
          : i > 0
          ? (l = i + "分" + o + "秒")
          : o > 0 && (l = o + "秒");
        return "距离下一轮抢宝还有", "距离下一轮抢宝还有" + l;
      }),
      (t.prototype.allowForceJewel = function (e) {
        1 == e
          ? ((this.btn_jewel_kaishiqiangbao.visible = !0),
            (this.label_jewel_level_number.visible = !1))
          : 0 == e &&
            ((this.btn_jewel_kaishiqiangbao.visible = !1),
            (this.label_jewel_level_number.visible = !0));
      }),
      (t.prototype.onDidClickStartAction = function () {
        var e = Math.floor(Global.roleLvl / 10);
        WebSocketService.send({ c: 2056, d: { lvl: e } }),
          WebSocketService.send({ c: 2057, d: { lvl: e } }),
          (this.second = 60),
          MatchOtherDialog.showMatchNormalDialog(
            "正在匹配对手...",
            this,
            this.onPiPeiDuiShouFunction,
            this.onQuitMatchFunction
          );
      }),
      (t.prototype.onCountTimeMethod = function () {
        this.second--,
          0 == this.second &&
            (Laya.timer.clear(this, this.onCountTimeMethod),
            MatchOtherDialog.closeMatch(),
            this.removeSelf());
      }),
      (t.prototype.onLoadStartQiangBaoData = function (e) {
        0 != e.code &&
          (ToastView.toastView(e.msg), MatchOtherDialog.closeMatch());
      }),
      (t.prototype.onPiPeiDuiShouFunction = function () {
        var e = Math.floor(Global.roleLvl / 10);
        WebSocketService.send({ c: 2056, d: { lvl: e, c: 1 } });
      }),
      (t.prototype.onQuitMatchFunction = function () {
        Laya.timer.clear(this, this.onCountTimeMethod);
      }),
      (t.prototype.dealCurrentMatchTitle = function (e) {
        var t = Math.floor(Global.roleLvl / 10) + 1 + "";
        return (
          (this.label_jewel_level_number.visible = !0),
          e == t
            ? ""
            : "您当前" + Global.roleLvl + "级，请前往" + t + "级宝库进行挖宝"
        );
      }),
      (t.prototype.onDidForceAction = function (e) {
        if ("item0" == e.target.name) {
          ((t = RulesView.showCaslRuleView("forcejewelGZSM")).y = 0),
            Laya.stage.addChild(t);
        } else if ("item1" == e.target.name) {
          var t = RulesView.showCaslRuleView("forcejewelJLSM");
          (t.y = 0), Laya.stage.addChild(t);
        }
      }),
      (t.prototype.onForceJewelBackFn = function () {
        Laya.timer.clear(this, this.timerCountDownJewelFn), this.removeSelf();
      }),
      t
    );
  })(ui.battlefield.forcejewelUI);
